import { createContext } from 'react'

import axios from 'axios'

const instance = axios.create({
    baseURL: 'http://localhost:3000/api/',
    timeout:6000
})

instance.interceptors.request.use(function (config) {
    return config;
}, function (error) {
    return Promise.reject(error)
})

instance.interceptors.response.use(function (response) {
    // 对响应数据做点什么
    return response;
}, function (error) {
    // 对响应错误做点什么
    return Promise.reject(error);
})

const axiosContext = createContext(instance)

export default axiosContext